package com.yiming.config;

import com.yiming.properties.SendMessageProperty;
import com.yiming.service.impl.SendMsgBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: 属性配置使用
 */
@Configuration
@EnableConfigurationProperties(value = SendMessageProperty.class)
@ConditionalOnProperty(prefix = "zym", name = "load", havingValue = "true")
public class ZymSendMsgBeanConfig {
    @Autowired
    private SendMessageProperty sendMessageProperty;

    @Bean(name = "zymSendMsgBiz")
    @ConditionalOnMissingBean
    public SendMsgBiz getSendMsgBiz() {
        SendMsgBiz sendMsgBiz = new SendMsgBiz();
        sendMsgBiz.setFactory(sendMessageProperty.getManufacturer());
        return sendMsgBiz;
    }
}
